<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>后台</title>
  <link rel="stylesheet" href="../css/layui-v2.4.3/layui/css/layui.css">
  <script src="../js/jquery-1.11.0.js" type="text/javascript" charset="utf-8"></script>
  <script src="../js/jquery.cookie.js" type="text/javascript" charset="utf-8"></script>
  <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <link rel="stylesheet" href="../css/manage.css">
  <script src="../js/manage_jumpwork.js"></script>
  <script src="../js/request.js"></script>
  <script type="text/javascript">
    $.removeCookie('admin');
    $.removeCookie('uId');
  </script>
</head>

<body class="layui-layout-body">
  <div class="layui-layout layui-layout-admin">
    <div class="layui-header">
      <div class="layui-logo">作品管理平台</div>
      <!-- 头部区域（可配合layui已有的水平导航） -->
      <ul class="layui-nav layui-layout-right">
        <li class="layui-nav-item">
          <a href="javascript:;">
            <img src="" class="layui-nav-img">
            信息科学与工程学院
          </a>
          <dl class="layui-nav-child">
            <dd><a href="">基本资料</a></dd>
            <dd><a href="">安全设置</a></dd>
          </dl>
        </li>
        <li class="layui-nav-item"><a href="#" onclick="OutLogin()">退出登录</a></li>
      </ul>
    </div>

    <div class="layui-side layui-bg-black">
      <div class="layui-side-scroll">
        <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
        <ul class="layui-nav layui-nav-tree" lay-filter="test">
          <li class="layui-nav-item layui-nav-itemed">
            <a class="" href="./manageworks.html">作品发布</a>
          </li>
          <li class="layui-nav-item">
            <a href="./manage.html" onclick="jumpcatch()">比赛发布</a>
          </li>
          <li class="layui-nav-item"><a href="./managestudent.html" onclick="jumpStudent()">学生管理</a></li>
        </ul>
      </div>
    </div>

    <div class="layui-body">
        <div id="searchBox">
            <div class="searchNext"></div>
            <div>
                <form class="navbar-form navbar-left" role="search">
                    <div class="form-group">
                        <input type="text" class="form-control" placeholder="Search" id="searchStudent"
                            onkeyup="myFunction()">
                    </div>
                    <button type="submit" class="btn btn-default">搜索</button>
                </form>
            </div>
            <div class="searchNext"></div>
        </div class="studentsForm">
        <table class="table table-hover table-striped">
            <thead>
                <tr>
                    <th>学号</th>
                    <th>姓名</th>
                    <th>作品名称</th>
                    <th>用户id</th>
                </tr>
            </thead>
            <tbody id="studentTable">
            </tbody>
        </table>
    </div>

    <div class="layui-footer">
      <!-- 底部固定区域 -->
      琴理工作室作品管理平台
    </div>
  </div>
  <script src="../layui-v2.4.3\layui/layui.js"></script>
  <script>
    // 获取传来数据加载表格
    $ajax({
  method: "GET",
  url: "http://39.97.237.157:8081/api/getallarticlesbytime",
  success: function (result) {
      console.log(result.data.length);
      var all = result.data;
        var works = $("tbody");
        for (var i = 0; i < all.length; i++) {
            works.append('<tr><td>'+all[i].studyNo+'</td><td>'+all[i].name+'</td><td>'+all[i].proName+'</td><td>'+all[i].uId+'</td></tr>');
        }
    }
})
    // 搜索功能
    function myFunction() {
        // 声明变量
        var input, filter, table, tr, td, i;
        input = document.getElementById("searchStudent");
        filter = input.value.toUpperCase();
        table = document.getElementById("studentTable");
        tr = table.getElementsByTagName("tr");

        // 循环表格每一行，查找匹配项
        for (i = 0; i < tr.length; i++) {
            td = tr[i].getElementsByTagName("td")[0];
            if (td) {
                if (td.innerHTML.toUpperCase().indexOf(filter) > -1) {
                    tr[i].style.display = "";
                } else {
                    tr[i].style.display = "none";
                }
            }
        }
    }
</script>
</body>

</html>